#!/bin/bash

# DevDeploy 数值任务API测试脚本
# 用法: ./test_numrical.sh [port]
# 默认端口: 8775

PORT=${1:-8775}

echo "🧪 DevDeploy数值任务API测试脚本"
echo "================================"
echo "测试端口: ${PORT}"
echo ""


# 测试预测功能
echo ""
echo "2. 测试预测功能..."
echo "发送预测请求..."

response=$(curl -s -X POST http://localhost:${PORT}/predict \
    -H "Content-Type: application/json" \
    -d '{"feature_0": 1.0, "feature_1": 2.0, "feature_2": 3.0, "feature_3": 4.0, "feature_4": 5.0}')

echo "预测结果:"
echo "$response" | python3 -m json.tool 2>/dev/null || echo "$response"

# 查找对应的docker-compose文件
COMPOSE_FILE=$(ls server/*/deployShuzhi/docker-compose.cpu*${PORT}.yml 2>/dev/null | head -1)

echo ""
echo "3. 服务管理命令:"
if [ -n "${COMPOSE_FILE}" ]; then
    echo "   查看日志: docker-compose -f ${COMPOSE_FILE} logs -f"
    echo "   停止服务: docker-compose -f ${COMPOSE_FILE} down"
    echo "   重启服务: docker-compose -f ${COMPOSE_FILE} restart"
else
    echo "   ⚠️  未找到对应的docker-compose配置文件"
fi

echo ""
echo "✅ 测试完成"

